import { AxiosResponse } from 'axios'
export interface ResponseResult {
    status: number
    code: string
    msg: string
    data: any
}

// 转成进制
export function conversionDécimale(num: number, decimale: number = 2): string {
    if (num) {
        switch (decimale) {
            case 2:
                return '0b' + (num).toString(decimale)
            case 8:
                return '0' + (num).toString(decimale)
            case 16:
                return '0x' + (num).toString(decimale)
            default:
                return ''
        }
    } else {
        return ''
    }
}

// 转换请求结果
export const responseFormat = (data: AxiosResponse) => {
    const result: ResponseResult = {
        status: data.status,
        code: data.data.code,
        msg: data.data.msg,
        data: data.data.result
    }
    return result
}